<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    request.setAttribute("basePath",basePath);
%>
<%@ include file="/resources/js/easyui/taglibs.jsp"%>
<%@ include file="/resources/js/wechat/_wechatui.jsp"%>
<%@ include file="/resources/js/easyui/_viewJS.jsp"%>
<!DOCTYPE>
<html>
<head>
    <title>增加场地</title>
</head>
<body>
<div class="loading"></div>
<!-- header -->
<header>
    <a href="${basePath}wechat/operate/place/listView" class="top_fh">增加场地</a>
</header>
<!-- header end -->

<div class="page">
    <div class="taocan_addcd">
        <ul>
            <form id="addform">
            <li><input type="text" name="address" id="address" class="addressName" placeholder="请输入地址信息"/></li>
                <input type="hidden" name="state" value="1"/>
            </form>
        </ul>
    </div>
    <div class="tcse_button"><a href="JavaScript:;" style="border-radius:3px;" id="addSubBtn">添加</a></div>
</div>

<script type="application/javascript">
    //限制场地名称输入框长度、类型
    $(".addressName").long({"element":".addressName","action":"keyup","stringl":"1","stringls":"10","reg":/^.{0,20}$/, "stavalue":"场地1"});

    function View(){
        var that = this;

        that.events = [
            { sel : '#addSubBtn', act : 'click', func : 'addSub' }
        ];

        that.addSub = function(){
            if($("#address").val().length!=0){
                $.ajax({
                    url:'${basePath}wechat/operate/place/add',
                    type : 'POST',
                    data : $("#addform").serialize(),
                    error: function (response) {
                        ViewHelper.func.ajaxWechatErrorMessage(response);
                    },
                    success: function (ret) {
                        if(ret.result) {
                            window.location = "${basePath}wechat/operate/place/listView";
                        }else{
                            alert(ret.info);
                        }
                    }
                });
            }else{
                alert("场地内容不能为空！");
            }

        };

        EventHandler.call(that, that.events);

        return that;
    }

    var view;

    $(function(){
        inherit(View, EventHandler);
        view = new View();
    });
</script>

</body>
</html>